// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.randomizedWorld.randomizedDeadSurvivor;

import zombie.core.Rand;
import zombie.iso.BuildingDef;
import zombie.iso.IsoWorld;
import zombie.iso.RoomDef;
import zombie.iso.objects.IsoDeadBody;

public final class RDSZombiesEating extends RandomizedDeadSurvivorBase {
    public RDSZombiesEating() {
        this.name = "Eating zombies";
        this.setChance(7);
        this.setMaximumDays(60);
    }

    @Override
    public boolean isValid(BuildingDef def, boolean force) {
        return IsoWorld.getZombiesEnabled() && super.isValid(def, force);
    }

    @Override
    public void randomizeDeadSurvivor(BuildingDef def) {
        RoomDef roomDef0 = this.getLivingRoomOrKitchen(def);
        IsoDeadBody isoDeadBody = RandomizedDeadSurvivorBase.createRandomDeadBody(roomDef0, Rand.Next(5, 10));
        if (isoDeadBody != null) {
            zombie.VirtualZombieManager.instance.createEatingZombies(isoDeadBody, Rand.Next(1, 3));
            RoomDef roomDef1 = this.getRoom(def, "kitchen");
            RoomDef roomDef2 = this.getRoom(def, "livingroom");
            if ("kitchen".equals(roomDef0.name) && roomDef2 != null && Rand.Next(3) == 0) {
                isoDeadBody = RandomizedDeadSurvivorBase.createRandomDeadBody(roomDef2, Rand.Next(5, 10));
                if (isoDeadBody == null) {
                    return;
                }

                zombie.VirtualZombieManager.instance.createEatingZombies(isoDeadBody, Rand.Next(1, 3));
            }

            if ("livingroom".equals(roomDef0.name) && roomDef1 != null && Rand.Next(3) == 0) {
                isoDeadBody = RandomizedDeadSurvivorBase.createRandomDeadBody(roomDef1, Rand.Next(5, 10));
                if (isoDeadBody == null) {
                    return;
                }

                zombie.VirtualZombieManager.instance.createEatingZombies(isoDeadBody, Rand.Next(1, 3));
            }

            def.bAlarmed = false;
        }
    }
}
